<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org/">
<head>
    <title>饼状图</title>
</head>
<body>
<!-- 为 ECharts 准备一个定义了宽高的 DOM -->
<div id="main" style="width: 1000px;height: 700px;"></div>
<script th:src="@{/static/echarts.min.js}" type="text/javascript" charset="utf-8"></script>
<script th:src="@{/static/jquery-2.1.4.js}" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript">
    // 基于准备好的dom，初始化echarts实例
    var myChart = echarts.init(document.getElementById('main'));

    $.post(
        '/category/echarts',
        function(result) {
            console.log(result);

            //-----------饼状图----------------
            var option = {
                title: {
                    text: '商品类型&类型下的二级分类',
                    subtext: '二级分类占一级分类的个数',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left'
                },
                series: [
                    {
                        name: 'Access From',
                        type: 'pie',
                        radius: '50%',
                        data: result.data,
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ]
            };
            myChart.setOption(option);
        },
        'json'
    );

</script>
</body>
</html>